<template>
  <div>
    <h2>添加用户和订单</h2>
    <form @submit.prevent="addUserAndOrder">
      <label>用户名：</label>
      <input v-model="user.username">
      <label>订单金额</label>
      <input v-model="order.payment">
      <button type="submit">提交</button>
    </form>
  </div>
</template>
<script>

import axios from "axios";

export default {
  data() {
    return {
      user: {
        username: '',
        // 其他用户属性
      },
      order: {
        payment: 0,
        user: {}
      }
    };
  },

  methods:{
    async addUserAndOrder(){
      try {
        this.order.user=this.user
        const response=await axios.post('http://localhost:9002/order/order',this.order);
        console.log('添加成功',response.data);
      }catch (error){
        console.error('添加失败',error);
      }
    }

  }
}


</script>